#ifndef LUAVALUE_HPP
#define LUAVALUE_HPP

/********************************************************************
	created:	2011/01/19
	filename: 	E:\C++\Red\src\Engine\Lua\Value.hpp
	author:		Red
	
	purpose:	Class containing all possible valuetype of Lua 
*********************************************************************/

#include "Config.hpp"
#include "Lua/lua.hpp"

namespace red {
	/// Forward Declaration of LuaValueType (to be used in LuaValue)
	class LuaValue;
	typedef std::vector<LuaValue> LuaValueTable;

	/// Union of all possible Lua Value Type, plus functions for easeofuse
	class REDAPI LuaValue{
	public:
		/// Constructor for a nil value
		LuaValue();

		/// Constructor for a bool value
		LuaValue(bool b);

		/// Constructor for a float value
		LuaValue(f32 f);

		/// Constructor for a double value
		LuaValue(f64 f);

		/// Constructor for a int value
		LuaValue(s32 s);

		/// Constructor for a string value
		LuaValue(const std::string &pString);

		/// Constructor for a const char* value
		LuaValue(const char* pStr);

		/// No Constructor for a Table Value, this instead
		/// @param L : Current Lua State
		/// @return : True if the complete table has been processed
		bool RetrieveTable(lua_State* L);

		/// Returns the LuaValue Type in string form
		std::string GetTypeName() const;

		// Getters in different type form
			f32			ToFloat()	const;
			s32			ToInt()		const;
			std::string ToString()	const;
			bool		ToBool()	const;
			LuaValue operator[](u32 i) const;

	private:
		/// Lua defined type
		int mDataType;

		// All possible types
		lua_Number	 	mNumber;	
		bool		 	mBool;
		std::string	 	mString;
		LuaValueTable	mTable;
	};

	typedef std::vector<LuaValue> LuaValueTable;
}

#endif // LUAVALUE_HPP
